from django import forms

from .models import *


class ArticleForms(forms.Form):
    title=forms.CharField(
        label='标题',
        max_length=30,
        min_length=4,
        error_messages={
            'min_length': '长度小于4',
            'max_length': '长度大于30',
        }
    )
    desc = forms.CharField(
        label='描述信息',
        max_length=60,
        min_length=4,
        error_messages={
            'min_length': '长度小于4',
            'max_length': '长度大于60',
        }
    )
    content=forms.CharField(
        label='文章内容',
        widget=forms.Textarea
    )
    cover=forms.FileField(
        label='封面图'
    )
    classes =forms.ModelChoiceField(
        label='分类',
        queryset=Classes.objects.all(),
        # label标签为空
        empty_label=None
    )
    label=forms.ModelMultipleChoiceField(
        label='标签',
        queryset=Label.objects.all()
    )
